﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using Petra.Gis;
using Petra.Gis.RenderingServices.PlanarBase ;
using Petra.Gis.ReferenceSystemServices;

namespace Petra.Gis.Drawing.GDIPlus
{

  public class MemGridMap : MapBase
  {

    protected Bitmap _outBitmap;

    
    public MemGridMap(int width, int height, ProjectedCoordinateSystem mapCrs, double mapScale)
      : base(width, height, mapCrs, mapScale, MapPaperUnits.px, "GridMap")
    {
      
      //initialize output bitmap
      _outBitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

      ////init transformation
      //DisplayTransformMatrix tmpMatrix = new DisplayTransformMatrix();
      //tmpMatrix.Translate(mapCrs.DefaultEnvelope.Left, mapCrs.DefaultEnvelope.Bottom);
      //double scale = (mapCrs.DefaultEnvelope.Right - mapCrs.DefaultEnvelope.Left) / width;
      //tmpMatrix.Scale(scale, (-1) * scale);

      //_renderer = (Renderer)new GridRenderer(this, Graphics.FromImage(_outBitmap), tmpMatrix);
    }




    public GridRenderer createRenderer(System.Type geomType)
    {

      throw new NotImplementedException();
    }

    protected override Renderer mapCreateRenderer(System.Type geomType)
    {

      return this.createRenderer(geomType);
    }




    protected override MapLegend mapLegend
    {
      get { return this.Legend; }
    }

    new public Legend Legend
    {
      get { return (Legend)_legend; }
    }




    public Image Draw()
    {

      refreshMapContent();
      return _outBitmap;
    }



    //protected override object mapDraw()
    //{
    //  return this.draw();
    //}

  }

}
